package Exercise;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;


class IntCmp implements Comparator<Integer> {
    @Override
    public int compare(Integer o1, Integer o2) {
        return o2.compareTo(o1);
    }
}

public class Test {

    public static void main(String[] args) {
        PriorityQueue<Integer> pq=new PriorityQueue<>(new IntCmp());
        pq.offer(10);
        pq.offer(2);
        pq.offer(300);
        System.out.println(pq.peek());

    }

    public static void main2(String[] args) {
        //创建一个空的优先级队列,底层默认容量是11
        PriorityQueue<Integer> pq=new PriorityQueue<>();
        pq.offer(10);
        pq.offer(2);
        pq.offer(300);
        System.out.println(pq.peek());

        //创建一个空的优先级队列,底层默认容量为initialCapacity
        PriorityQueue<Integer> pq2=new PriorityQueue<>(100);

        //用已有的ArrayList对象来构造一个优先级队列的对象,
        ArrayList<Integer> list=new ArrayList<>();
        list.add(10);
        list.add(2);
        list.add(300);
        PriorityQueue<Integer> pq3=new PriorityQueue<>(list);
        System.out.println(pq3.size());
        System.out.println(pq3.peek());
    }
    public static void main1(String[] args) {
        TestHeap testHeap=new TestHeap();
        int[] array={27,15,19,18,28,34,65,49,25,37};
        testHeap.init(array);
        testHeap.createBigHeap();
        testHeap.poll();
//        testHeap.offer(80);

    }
}
